from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
from dhm.models.user.consumer import Consumer

class InfoView(APIView):
    permission_classes=[IsAuthenticated]
    def get(self, request):
        user = request.user
        consumer = Consumer.objects.get(user=user)
        return Response({
            'result': "success",
            'id': user.id,
            'username': consumer.username,
            'is_superuser': consumer.is_superuser,
            'photo': consumer.photo,
            'phone_number': consumer.phone_number,
            'consumer_address': consumer.consumer_address,
        })
